$(function(){
   $('#login-btn').click(function(){
       //获得输入框的数据
       let userval=$('#username').val();
       let pwdval=$('#pwd').val();
      

       $.ajax({
           type:"post",
           url:"http://139.9.177.51:3333/p2p/login",
           data:{
                username:userval,
                pwd:pwdval
           },
           dataType:"json",
           success:function(data){
               //console.log(data);

               if(data.code==200){
                   alert('恭喜登录成功')

                   localStorage.setItem('username',data.data.nickname);

                   sessionStorage.setItem('userid',data.data.id)
                  
                   localStorage.setItem('time',new Date().getTime()+10000*1000);
                   location.href='/'


               }else{
                   alert('登录失败！')
               }

           }
       })
   })
})